package org.jeecg.modules.paycenter.channel.hundsun;

import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.HttpTools;
import org.jeecg.modules.wlhy.bill.entity.HyShippingNoteBill;
import org.jeecg.modules.wlhy.hydriverbank.entity.HyDriverBank;
import org.jeecg.modules.wlhy.hypfaccount.entity.HyPfAccount;
import org.jeecg.modules.wlhy.utils.HyCfgUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HundSunUtil {
    @Value(value = "${paycenter.url:http://127.0.0.1:9900/wlhy168/paycenter}")
    private String _baseUrl;

    public Result<?> send(String url , String data) {
        try {
            String ret = HttpTools.postJson(_baseUrl + url, data);
            return JSONObject.parseObject(ret, Result.class);
        }catch (Exception ex){
            return Result.error(ex.getMessage());
        }
    }

    public Result<?> send(String url , JSONObject data){
        try {
            String ret  = HttpTools.postJson(_baseUrl + url, data);
            return JSONObject.parseObject(ret,Result.class);
        }catch (Exception ex){
            return Result.error(ex.getMessage());
        }
    }

    public Result<?> getPtAccountInfo(String acctNo) {
        JSONObject data = new JSONObject();
        data.put("acctNo", acctNo);
        return send("/hundsun/getPtAccountInfo", data);
    }

    public Result<?> downloadShippingBillHd(HyShippingNoteBill bill) {
        String data = JSONObject.toJSONString(bill);
        return send("/hundsun/downloadShippingBillHd", data);
    }

    public Result<?> batchDownloadShippingBillHd(List<String> ids) {
        JSONObject data = new JSONObject();
        data.put("ids", ids);
        return send("/hundsun/batchDownloadShippingBillHd", data);
    }
}
